<template>
    <div class="login">
        <div class="dox">
            <div style="margin-top:50px; margin-left: 100px;">
                <span class="span">THINK · 智慧校园</span>
            </div>
            <div style="margin-left: 120px;">
                <span class="span">后台管理系统</span>
            </div>
            <el-form ref="sysUser" :model="sysUser" label-width="80px" style="margin-top: 30px;">
                <el-form-item label="用户名称">
                    <el-input v-model="sysUser.userName"></el-input>
                </el-form-item>
                <el-form-item label="用户密码">
                    <el-input v-model="sysUser.password" type="password"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="userLogin">登录</el-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>



<script>

import axios from 'axios'
import { getToken, setToken, removeToken } from '@/utils/auth'

export default {
    name:'Login',
    data(){
        return{
            sysUser: {
                userName: "",
                password: ""
            }
        }
    },
    methods: {
        userLogin() {
            //定义请求头
            const headers = {
                isToken: false
            }
            axios.post("/api/manager/user/login", this.sysUser, {headers})
                .then((res) => {
                    console.log(res.data)
                    if (res.data.code == 200) {

                        setToken(res.data.data.token)
                        // 登录成功后的处理
                        // this.$router.push({ name: 'index', params: { nickName: res.data.data.nickName } });
                        
                        this.$router.push("/home").catch(()=>{});
                        localStorage.setItem("nickName",res.data.data.nickName);
                        localStorage.setItem("thisUserId",res.data.data.thisUserId);

                    }else {
                        this.$message.error('错了哦，' + res.data.message);
                    }
                })
        }
    }
}
</script>
<style scoped>
.login{
    width: 100%;
    height: 600px;
    position: relative;
    background-color:rgb(106, 106, 230);
}
.dox{
    margin: 50px auto;
    width: 400px;
    height: 500px;
    background-color: #fff;
    position: absolute;
    top: 20px;
    left: 650px;
}
.span{
    font-family: 'Arial Negreta', 'Arial';
    font-weight: 700;
    font-style: normal;
    font-size: 26px;
    color: rgba(0, 153, 255, 0.709803921568627);
    text-align: center;
    line-height: 35px;
}
.el-input{
    width: 280px;
}
.el-button{
    width: 280px;
    margin-top: 50px;
}
</style>